package com.sh.二叉树;

/**
 * @Auther: sh
 * @Version 1.0
 * @Description:
 */
public class 对称二叉树 {
    public static void main(String[] args) {

    }

    public boolean isSymmetric(TreeNode root) {
        if (root==null){
            return true;
        }
        boolean b = funIS(root.left, root.right);
        return b;

    }

    private boolean funIS(TreeNode left, TreeNode right) {

        if (left==null && right!=null)
            return false;
        if (left!=null && right==null){
            return false;
        }
        if (left==null && right==null){
            return true;
        }
        if (left.val != right.val)
            return false;
        return funIS(left.left, right.right) && funIS(left.right, right.left);
    }
}

